	var labels=[];
	var datas=[];
	var labels1=[];
	var datas1=[];
	var customer="";
	var cargo_2 = "";	
	var myChartcargo_2="";
	var cargo_3 = "";	
	var myChartcargo_3="";
	var parameter= "";
	var routename="";
	$(function(){
		var cargonames = GetQueryString("cargoname");
		routename=decodeURIComponent(window.atob(cargonames));
		$(".alltitle").html(routename);
		parameter={"goodstype":routename,"startTime":"2017-01-01"};
		mounth();
		cargoClassAnalysis_MonthlyTrends();
		//按航线
 		cargoClassAnalysis_route();
	});
	Chart.defaults.global.defaultFontColor = '#fff';
	
	function GetQueryString(name){
	     var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
	     var r = window.location.search.substr(1).match(reg);
	     if(r!=null)return  unescape(r[2]); return null;
	}
	
	
	//	前十大客户
	function mounth(){
		$(".loding1").show();
			$.ajax({
			type: "post",
	        async: true,
	        url: "/enReport/cargoClassAnalysis_customer",
	        data: parameter,
	        dataType: "json",
	        success: function(data){
	        	var str="";
	        	console.log(data);
			    for(var i=0;i<data.length;i++){
			    str+='<li class="goodsnameli">'+
						'<p class="goodsname">'+data[i].fname_l2+'</p><p class="goodsacount">'+data[i].teu+'</p>'+
					'</li>'
			    }
			    $("#route_goods").html(str);
			     $(".loding1").hide(); 
			    $(".goodsnameli").click(function(){
			    	if($(this).hasClass("colorli")){
			    		parameter={"goodstype":routename,"startTime":"2017-01-01"};
			    		$(this).removeClass("colorli");
			    	}else{
			    		$(this).addClass("colorli").siblings().removeClass("colorli");
			    		customer=$(this).find("p").eq(0).html();
			    		parameter={"goodstype":routename,"startTime":"2017-01-01","customer":customer};
			    	}
			    	myChartcargo_2.data.labels.pop();
				    myChartcargo_2.data.datasets.forEach((dataset) => {
				        dataset.data.pop();
				    });
				    
				    myChartcargo_3.data.labels.pop();
				    myChartcargo_3.data.datasets.forEach((dataset) => {
				        dataset.data.pop();
				    });
				    
				    cargoClassAnalysis_route();
				    cargoClassAnalysis_MonthlyTrends();
			    })
	        }
		});
	}
	//按月度趋势
 var  cargoClassAnalysis_MonthlyTrends = function(){
 		$(".loding3").show();
 		$.ajax({
		type: "post",
        async: true,
        url: "/enReport/cargoClassAnalysis_MonthlyTrends",
        data: parameter,
        dataType: "json",
        success: function(data){
        	label1s=[];
        	data1s=[];
        	for(var i=0;i<data.length;i++){
        		label1s.push(data[i].month);
        		datas1.push(data[i].teu);
        	}
        	cargo_3 = document.getElementById('cargo_3').getContext('2d');	
			myChartcargo_3 = new Chart(cargo_3, {
				type: 'line',
				data: {
					labels: label1s,
					datasets: [{
						label: "数据一",
						borderWidth: '3',
						backgroundColor: "rgba(94,151,200,0.5)",
						borderColor: "rgba(94,151,200,1)",
						pointBackgroundColor: "#46ffc3",
						pointStrokeColor: "#fff",
						data: datas1
					}]
				},
				options: {
					maintainAspectRatio: true,
					scales: {
				        xAxes: [{
				            ticks: {
				            	autoSkip: false,
				            }
				        }]
				    },
					legend: {
						labels: {
							
						},
						display: false,
					},
				},
			});
			$(".loding3").hide();
        }
	});
 }
	
var cargoClassAnalysis_route  =function(){
	$(".loding2").show();
		$.ajax({
		type: "post",
        async: true,
        url: "/enReport/cargoClassAnalysis_route",
        data: parameter,
        dataType: "json",
        success: function(data){
        	labels=[];
        	datas=[];
        	for(var i=0;i<data.length;i++){
        		labels.push(data[i].service_name);
        		datas.push(data[i].teu);
        	}
        	cargo_2 = document.getElementById('cargo_2').getContext('2d');	
			myChartcargo_2 = new Chart(cargo_2, {
				type: 'bar',
				data: {
					labels: labels,
					datasets: [{
						label: "数据一",
						borderWidth: '3',
						backgroundColor: [
							"rgba(25,198,198,0.5)",
							"rgba(202,127,50,0.5)",
							"rgba(94,151,200,0.5)",
							"rgba(210,72,91,0.5)",
							"rgba(206,120,222,0.5)",
							"rgba(94,151,200,0.5)"
						],
						borderColor: [
							"rgba(25,198,198,1)",
							"rgba(202,127,50,1)",
							"rgba(94,151,200,1)",
							"rgba(210,72,91,1)",
							"rgba(206,120,222,1)",
							"rgba(94,151,200,1)"
						],
						pointBackgroundColor: "#46ffc3",
						pointStrokeColor: "#fff",
						data: datas
					}]
				},
				options: {
					maintainAspectRatio: true,
					scales: {
				        xAxes: [{
				            ticks: {
				            	autoSkip: false,
				            }
				        }],
				        yAxes: [{
				            ticks: {
//				            	suggestedMin: 0,
				            	min: 0
				            }
				        }]
				    },
					legend: {
						labels: {
							
						},
						display: false,
					},
				},
			});
			$(".loding2").hide();
        }
	});
}
